<template>
<h1>El- 表格组件</h1>
  <!--  Ctrl + F -->
<!--  <el-table :data="tableData" stripe style="width: 100%">-->
<!--    <el-table-column prop="date" label="日期" width="180" />-->
<!--    <el-table-column prop="name" label="姓名" width="180" />-->
<!--    <el-table-column prop="address" label="住址" />-->
<!--  </el-table>-->

  <el-table :data="arr" stripe style="width: 100%" >
    <el-table-column  type="selection" width="80"></el-table-column>
    <el-table-column  label="编号" type="index" width="80"></el-table-column>
    <el-table-column  prop="name" label="姓名" width="180" />
    <el-table-column  prop="salary" label="工资" width="180" />
    <el-table-column  prop="job" label="工作" />
    <!--    -->
    <el-table-column>
      <template #default="scope">
        <el-button type="primary" @click="del(scope.$index,scope.row)">删除</el-button>
      </template>
    </el-table-column>
  </el-table>

</template>


<script setup>
import {ref} from "vue";

const tableData = [
  {
    date: '2016-05-03',
    name: 'Tom',
    address: 'No. 189, Grove St, Los Angeles',
  },
  {
    date: '2016-05-02',
    name: 'Tom',
    address: 'No. 189, Grove St, Los Angeles',
  },
  {
    date: '2016-05-04',
    name: 'Tom',
    address: 'No. 189, Grove St, Los Angeles',
  },
  {
    date: '2016-05-01',
    name: 'Tom',
    address: 'No. 189, Grove St, Los Angeles',
  },
]
const arr = ref([
    {name:'张三',salary:6000,job:'销售员'},
    {name:'李四',salary:3000,job:'维修员'},
    {name:'王五',salary:4000,job:'护林员'},
    {name:'赵六',salary:9000,job:'程序员'}]
)

const del = (index,row) => {
  if (confirm("确定要删除" + row.name + "吗？")){
    arr.value.splice(index,1)
  }
}

</script>

<style scoped>

</style>